#include "AboutScene.h"
#include "data/LabelStringProvider.h"
#include "logic/GameLogic.h"
#include <string>

using namespace cocos2d;

bool CAboutLayer::init()
{
	if(!CCLayerColor::initWithColor(ccc4(41,57,85,255)))
		return false;

	CCSprite* pAboutBG = CCSprite::create("about_back.png");
	pAboutBG->setPosition(ccp(540/2, 960/2));
	this->addChild(pAboutBG);
	
	CLableStringProvider* pLabelString = CGameLogic::shareInstance()->getLabelStingProvider();
	std::string strAbout = pLabelString->getStingByName("about");
	CCLabelTTF* label_about = CCLabelTTF::create();
	label_about->initWithString(strAbout.c_str(), "Arial", 30);
	label_about->setColor(ccc3(233, 232, 255));
	label_about->setDimensions(CCSize(450,650));
	label_about->setAnchorPoint(ccp(0,1));
	label_about->setPosition(ccp(25, 675));
	
	pAboutBG->addChild(label_about);

	CCSprite* back_normal = CCSprite::create("back.png");
	CCSprite* back_selected = CCSprite::create("back.png");
	back_selected->setScale(1.2);
	CCMenuItem* item = CCMenuItemSprite::create(back_normal,back_selected,
		this,menu_selector(CAboutLayer::onMenuBack));
	item->setPosition(ccp(450,50));

	CCMenu* menu = CCMenu::create(item,NULL);
	menu->setAnchorPoint(ccp(0,0));
	menu->setPosition(ccp(0,0));
	this->addChild(menu);

	return true;
}

void CAboutLayer::onMenuBack( cocos2d::CCObject* pSender )
{
	CGameLogic::shareInstance()->setState(EMainState::MENU_SCENE);
}

